# 解析XML实践
from xml.dom.minidom import parse

string_list = []
string_list2 = []

# 读取文件
dom = parse('strings.xml')
# 获取文档元素对象
data = dom.documentElement
# 获取 student
strings = data.getElementsByTagName('string')
for string in strings:
    name = string.getAttribute('name')
    value = string.childNodes[0].nodeValue
    print(name, value)
    string_list.append(value)

# 读取文件
dom = parse('strings-en.xml')
# 获取文档元素对象
data = dom.documentElement
# 获取 student
strings = data.getElementsByTagName('string')
for string in strings:
    name = string.getAttribute('name')
    value = string.childNodes[0].nodeValue
    print(name, value)
    string_list2.append(value)

with open("result.txt", "w") as f:
    for index, s in enumerate(string_list):
        f.write('"{}":"{}";\n'.format(string_list[index], string_list2[index]))
